/**
 * 
 */
package de.cbf.cam.dsa.facet.weapon_ranged.editor;

import java.beans.IndexedPropertyChangeEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

import de.cbf.cam.dsa.entity.edit.talent.resolver.service_resolver.IServiceResolver_EntityTalent;
import de.cbf.cam.dsa.facet.talent.FacetTalent;
import de.cbf.cam.dsa.facet.weapon_ranged.FacetWeaponRanged;
import de.cbf.cam.dsa.facet.weapon_ranged.helper.WeaponRanged_CombatValues;
import de.cbf.util.db.interfaces.exceptions.EntityLoadException;
import de.cbf.util.entity.edit.category_tree.dialogs.DialogChooseEntity;
import de.cbf.util.entity.edit.category_tree.helper.UUIDString;
import de.cbf.util.entity.facet.edit.composites.factorys.AbstractFacetSectionFactory;
import de.cbf.util.entity.facet.edit.controller.AbstractControllerEditFacet;
import de.cbf.util.entity.facet.entities.EntityCategorized;
import de.cbf.util.entity.facet.entities.EntityFacetReferences;
import de.cbf.util.ui.listener.IUiChangeListener;
import de.cbf.util.ui.listener.UiChangeEvent;
import de.cbf.util.uuidheader.entities.UUIDReference;

/**
 * @author Nebelritter
 * 	
 */
public class ControllerEditorFacetWeaponRanged  extends AbstractControllerEditFacet<FacetWeaponRanged> {
	private static final Log logger = LogFactory.getLog(ControllerEditorFacetWeaponRanged.class);

	public static final String TEXT_STATE_EVENT_Tp_ERROR					= "Tp setting not correct";
	public static final String TEXT_STATE_EVENT_Tp_WARNING					= FacetWeaponRanged.TEXT_UNSET_TP;
	public static final String TEXT_STATE_EVENT_LoadingActions_ERROR		= "LoadingActions setting not correct";
	public static final String TEXT_STATE_EVENT_LoadingActions_WARNING		= FacetWeaponRanged.TEXT_UNSET_LOADING_ACTIONS;
	public static final String TEXT_STATE_EVENT_RangeMin_ERROR				= "RangeMin setting not correct";
	public static final String TEXT_STATE_EVENT_RangeMin_WARNING			= FacetWeaponRanged.TEXT_UNSET_RANGE_MIN;
	public static final String TEXT_STATE_EVENT_RangeVeryShort_ERROR		= "RangeVeryShort setting not correct";
	public static final String TEXT_STATE_EVENT_RangeVeryShort_WARNING		= FacetWeaponRanged.TEXT_UNSET_RANGE_VERY_SHORT;
	public static final String TEXT_STATE_EVENT_RangeShort_ERROR			= "RangeShort setting not correct";
	public static final String TEXT_STATE_EVENT_RangeShort_WARNING			= FacetWeaponRanged.TEXT_UNSET_RANGE_SHORT;
	public static final String TEXT_STATE_EVENT_RangeMedium_ERROR			= "RangeMedium setting not correct";
	public static final String TEXT_STATE_EVENT_RangeMedium_WARNING			= FacetWeaponRanged.TEXT_UNSET_RANGE_MEDIUM;
	public static final String TEXT_STATE_EVENT_RangeLong_ERROR				= "RangeLong setting not correct";
	public static final String TEXT_STATE_EVENT_RangeLong_WARNING			= FacetWeaponRanged.TEXT_UNSET_RANGE_LONG;
	public static final String TEXT_STATE_EVENT_RangeExtremelyLong_ERROR	= "RangeExtremelyLong setting not correct";
	public static final String TEXT_STATE_EVENT_RangeExtremelyLong_WARNING	= FacetWeaponRanged.TEXT_UNSET_RANGE_EXTREMELY_LONG;
	public static final String TEXT_STATE_EVENT_DamageVeryShort_ERROR		= "DamageVeryShort setting not correct";
	public static final String TEXT_STATE_EVENT_DamageVeryShort_WARNING		= FacetWeaponRanged.TEXT_UNSET_DAMAGE_VERY_SHORT;
	public static final String TEXT_STATE_EVENT_DamageShort_ERROR			= "DamageShort setting not correct";
	public static final String TEXT_STATE_EVENT_DamageShort_WARNING			= FacetWeaponRanged.TEXT_UNSET_DAMAGE_SHORT;
	public static final String TEXT_STATE_EVENT_DamageMedium_ERROR			= "DamageMedium setting not correct";
	public static final String TEXT_STATE_EVENT_DamageMedium_WARNING		= FacetWeaponRanged.TEXT_UNSET_DAMAGE_MEDIUM;
	public static final String TEXT_STATE_EVENT_DamageLong_ERROR			= "DamageLong setting not correct";
	public static final String TEXT_STATE_EVENT_DamageLong_WARNING			= FacetWeaponRanged.TEXT_UNSET_DAMAGE_LONG;	
	public static final String TEXT_STATE_EVENT_DamageExtremelyLong_ERROR	= "DamageExtremelyLong setting not correct";
	public static final String TEXT_STATE_EVENT_DamageExtremelyLong_WARNING	= FacetWeaponRanged.TEXT_UNSET_DAMAGE_EXTREMELY_LONG;

	public static final String DIALOG_TITLE_CHOOSE_TALENT	= "Choose Talent for ranged weapon...";
	public static final String TEXT_SECTION_TALENTS			= "Talents..";

	public static final String TEXT_ERROR_DIALOG_TITLE				= "Error";
	public static final String TEXT_ERROR_DIALOG_MESSAGE			= "There was an error loading the talents";
			
	protected static StateEvent STATE_EVENT_Tp_ERROR 					= new StateEvent(TEXT_STATE_EVENT_Tp_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_Tp_WARNING					= new StateEvent(TEXT_STATE_EVENT_Tp_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_LoadingActions_ERROR 		= new StateEvent(TEXT_STATE_EVENT_LoadingActions_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_LoadingActions_WARNING		= new StateEvent(TEXT_STATE_EVENT_LoadingActions_WARNING, StateEvent.STATE_WARNING);
	protected static StateEvent STATE_EVENT_RangeMin_ERROR				= new StateEvent(TEXT_STATE_EVENT_RangeMin_ERROR, StateEvent.STATE_ERROR);
	protected static StateEvent STATE_EVENT_RangeMin_WARNING 			= new StateEvent(TEXT_STATE_EVENT_RangeMin_WARNING, StateEvent.STATE_WARNING);
	protected static StateEvent STATE_EVENT_RangeVeryShort_ERROR 		= new StateEvent(TEXT_STATE_EVENT_RangeVeryShort_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_RangeVeryShort_WARNING		= new StateEvent(TEXT_STATE_EVENT_RangeVeryShort_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_RangeShort_ERROR 			= new StateEvent(TEXT_STATE_EVENT_RangeShort_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_RangeShort_WARNING			= new StateEvent(TEXT_STATE_EVENT_RangeShort_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_RangeMedium_ERROR 			= new StateEvent(TEXT_STATE_EVENT_RangeMedium_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_RangeMedium_WARNING			= new StateEvent(TEXT_STATE_EVENT_RangeMedium_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_RangeLong_ERROR 			= new StateEvent(TEXT_STATE_EVENT_RangeLong_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_RangeLong_WARNING			= new StateEvent(TEXT_STATE_EVENT_RangeLong_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_RangeExtremelyLong_ERROR	= new StateEvent(TEXT_STATE_EVENT_RangeExtremelyLong_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_RangeExtremelyLong_WARNING	= new StateEvent(TEXT_STATE_EVENT_RangeExtremelyLong_WARNING, StateEvent.STATE_WARNING);
	protected static StateEvent STATE_EVENT_DamageVeryShort_ERROR 		= new StateEvent(TEXT_STATE_EVENT_DamageVeryShort_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_DamageVeryShort_WARNING		= new StateEvent(TEXT_STATE_EVENT_DamageVeryShort_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_DamageShort_ERROR 			= new StateEvent(TEXT_STATE_EVENT_DamageShort_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_DamageShort_WARNING			= new StateEvent(TEXT_STATE_EVENT_DamageShort_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_DamageMedium_ERROR 			= new StateEvent(TEXT_STATE_EVENT_DamageMedium_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_DamageMedium_WARNING		= new StateEvent(TEXT_STATE_EVENT_DamageMedium_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_DamageLong_ERROR 			= new StateEvent(TEXT_STATE_EVENT_DamageLong_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_DamageLong_WARNING			= new StateEvent(TEXT_STATE_EVENT_DamageLong_WARNING, StateEvent.STATE_WARNING); 
	protected static StateEvent STATE_EVENT_DamageExtremelyLong_ERROR 	= new StateEvent(TEXT_STATE_EVENT_DamageExtremelyLong_ERROR, StateEvent.STATE_ERROR); 	
	protected static StateEvent STATE_EVENT_DamageExtremelyLong_WARNING	= new StateEvent(TEXT_STATE_EVENT_DamageExtremelyLong_WARNING, StateEvent.STATE_WARNING);
	
	protected static final UUIDReference INIT_TALENT = null;
	
	protected CompositeEditWeaponRanged	compositeEditWeaponRanged;
	protected NumberFormat format;	
	protected IServiceResolver_EntityTalent serviceResolverTalents;
	
	protected UUIDReference activeTalent;
	@Override
	protected void init() {
		super.init();
		format = NumberFormat.getInstance();
		pclFacetWeaponRanged = new PCLFacetWeaponRanged();
		uilFacetWeaponRanged = new UILFacetWeaponRanged();
		
		activeTalent = INIT_TALENT;
	}
	@Override
	protected AbstractFacetSectionFactory createSectionFactory() {		
		return new SectionFactoryWeaponRanged();
	}

	@Override
	protected FacetWeaponRanged createNewFacet() {		
		return new FacetWeaponRanged();
	}

	@Override
	public Class<FacetWeaponRanged> getFacetClass() {		
		return FacetWeaponRanged.class;
	}
		
	/**
	 * @param talents 
	 *
	 */
	public void handleTalentsSelected() {
		if(facet == null)return;
		UUID selectedTalentUUID = compositeEditWeaponRanged.getSelectedTalentUUID();		
		if(selectedTalentUUID != null){
			activeTalent = facet.getTalentReferenceForUUID(selectedTalentUUID);
			compositeEditWeaponRanged.setGroupWeaponValuesTalentText(activeTalent.getSavedName());
			compositeEditWeaponRanged.setStatusButtonTalentDeleteEnabled(true);
			compositeEditWeaponRanged.setStatusWeaponValuesEnabled(true);
			updateWeaponValues(facet.getWeaponValuesByTalent(activeTalent));
		}else{			
			activeTalent = INIT_TALENT;
			compositeEditWeaponRanged.setGroupWeaponValuesTalentText(null);
			compositeEditWeaponRanged.setStatusButtonTalentDeleteEnabled(false);
			compositeEditWeaponRanged.setStatusWeaponValuesEnabled(false);
		}
	}

	/**	 */
	public void handleTalentsAdd() {
		// LATER add condition for that talents use (like KK>=15)
		DialogChooseEntity dialog = new DialogChooseEntity(compositeEditWeaponRanged.getShell());
		//customize dialog
		dialog.setDialogTitle(DIALOG_TITLE_CHOOSE_TALENT);
		dialog.setSectionTitle(TEXT_SECTION_TALENTS);
		dialog.setActiveBaseFacet(FacetTalent.class);
		dialog.setUUIDForUncategorized(EntityCategorized.CATEGORY_UNCATEGORIZED_UUID_DEFAULT);
		dialog.setNameForUncategorized(EntityCategorized.CATEGORY_UNCATEGORIZED_NAME_DEFAULT);
		boolean errorInLoadingEntities = false;
		try {					
			Collection<EntityFacetReferences> elements = serviceResolverTalents.resolveAllEntities();	
			logger.debug("Number of Talents resolved: "+elements.size());			
			dialog.setEntityStructure(new ArrayList<EntityCategorized>(elements));
			errorInLoadingEntities = elements == null || elements.isEmpty();
		} catch (EntityLoadException e) {
			logger.error(e);					
			errorInLoadingEntities = true;
		}
		if(errorInLoadingEntities){			
			Shell parentShell			= compositeEditWeaponRanged.getShell();
			String dialogTitle			= TEXT_ERROR_DIALOG_TITLE;			
			String dialogMessage		= TEXT_ERROR_DIALOG_MESSAGE;			
			MessageDialog.openError(parentShell, dialogTitle, dialogMessage);			
			return;
		}
		//pre set value
		String selectedTalentName	= compositeEditWeaponRanged.getSelectedTalentName();
		UUID selectedTalentUUID		= compositeEditWeaponRanged.getSelectedTalentUUID();
		dialog.setValue(new UUIDString(selectedTalentUUID, selectedTalentName));		
		
		if(dialog.open() == DialogChooseEntity.OK){
			UUIDString chosenTalent = dialog.getValue();		
			//
			UUIDReference talentReference = 
					UUIDReference.extractUUIDReference(chosenTalent.uuid,chosenTalent.string, EntityCategorized.class);				
			WeaponRanged_CombatValues currentWeaponValues = facet.getWeaponValuesByTalent(activeTalent);
			WeaponRanged_CombatValues newValues;
			if(currentWeaponValues != null ){
				// clone weapon values hereby, if any values are active
				try {
					newValues = (WeaponRanged_CombatValues)currentWeaponValues.clone();
				} catch (CloneNotSupportedException e) {
					newValues = new WeaponRanged_CombatValues();
				}
			}else{
				newValues = new WeaponRanged_CombatValues();
			}
			facet.setWeaponValuesByTalent(talentReference, newValues);			
		}		
	}

	/** */
	public void handleTalentsDelete() {		
		UUID  selectedTalentUUID = compositeEditWeaponRanged.getSelectedTalentUUID();
		if(selectedTalentUUID != null){
			UUIDReference reference = facet.getTalentReferenceForUUID(selectedTalentUUID);
			facet.removeWeaponValuesByTalent(reference);
			if(reference.equals(activeTalent)){
				activeTalent = INIT_TALENT;
			}
		}		
	}
	
	public void modifyTp(UUID talentUUID, String newTp) {	
		if(facet == null) return;	
		UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
		facet.setTp(talentReference,newTp);		
	}
	
	public void modifyLoadingActions(UUID talentUUID,String newLoadingActions) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationLoadingActionsStatus(false);
			}
			removeStateEvent(STATE_EVENT_LoadingActions_ERROR);
			valueNumber =  format.parse(newLoadingActions);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setLoadingActions(talentReference,valueInteger);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationLoadingActionsStatus(true);	
			}
			addStateEvent(STATE_EVENT_LoadingActions_ERROR);			
		}	
	}
	
	public void modifyRangeMin(UUID talentUUID, String newRangeMin) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeMinStatus(false);
			}
			removeStateEvent(STATE_EVENT_RangeMin_ERROR);
			valueNumber =  format.parse(newRangeMin);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeMin(talentReference,valueInteger.doubleValue());
			}
			if (valueNumber instanceof Double) {
				Double valueDouble = (Double) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeMin(talentReference,valueDouble.doubleValue());
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeVeryShortStatus(true);	
			}
			addStateEvent(STATE_EVENT_RangeVeryShort_ERROR);			
		}	
	}
	
	public void modifyRangeVeryShort(UUID talentUUID, String newRangeVeryShort) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeVeryShortStatus(false);
			}
			removeStateEvent(STATE_EVENT_RangeVeryShort_ERROR);
			valueNumber =  format.parse(newRangeVeryShort);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeVeryShort(talentReference,valueInteger.doubleValue());
			}
			if (valueNumber instanceof Double) {
				Double valueDouble = (Double) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeVeryShort(talentReference,valueDouble.doubleValue());
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeVeryShortStatus(true);	
			}
			addStateEvent(STATE_EVENT_RangeVeryShort_ERROR);			
		}	
	}
	
	public void modifyRangeShort(UUID talentUUID, String newRangeShort) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeShortStatus(false);
			}
			removeStateEvent(STATE_EVENT_RangeShort_ERROR);
			valueNumber =  format.parse(newRangeShort);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeShort(talentReference,valueInteger.doubleValue());
			}
			if (valueNumber instanceof Double) {
				Double valueDouble = (Double) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeShort(talentReference,valueDouble);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeShortStatus(true);	
			}
			addStateEvent(STATE_EVENT_RangeShort_ERROR);			
		}	
	}
	
	public void modifyRangeMedium(UUID talentUUID, String newRangeMedium) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeMediumStatus(false);
			}
			removeStateEvent(STATE_EVENT_RangeMedium_ERROR);
			valueNumber =  format.parse(newRangeMedium);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeMedium(talentReference,valueInteger.doubleValue());
			}
			if (valueNumber instanceof Double) {
				Double valueDouble = (Double) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeMedium(talentReference,valueDouble);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeMediumStatus(true);	
			}
			addStateEvent(STATE_EVENT_RangeMedium_ERROR);			
		}	
	}
	
	public void modifyRangeLong(UUID talentUUID, String newRangeLong) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeLongStatus(false);
			}
			removeStateEvent(STATE_EVENT_RangeLong_ERROR);
			valueNumber =  format.parse(newRangeLong);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeLong(talentReference,valueInteger.doubleValue());
			}
			if (valueNumber instanceof Double) {
				Double valueDouble = (Double) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeLong(talentReference,valueDouble);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeLongStatus(true);	
			}
			addStateEvent(STATE_EVENT_RangeLong_ERROR);			
		}	
	} 
	
	public void modifyRangeExtremelyLong(UUID talentUUID,String newRangeExtremelyLong) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeExtremelyLongStatus(false);
			}
			removeStateEvent(STATE_EVENT_RangeExtremelyLong_ERROR);
			valueNumber =  format.parse(newRangeExtremelyLong);		
			if (valueNumber instanceof Long) {
				Long valueLong = (Long) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeExtremelyLong(talentReference,valueLong.doubleValue());
			}
			if (valueNumber instanceof Double) {
				Double valueDouble = (Double) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setRangeExtremelyLong(talentReference,valueDouble);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationRangeExtremelyLongStatus(true);	
			}
			addStateEvent(STATE_EVENT_RangeExtremelyLong_ERROR);			
		}	
	}	
	
	public void modifyDamageVeryShort(UUID talentUUID,String newDamageVeryShort) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageVeryShortStatus(false);
			}
			removeStateEvent(STATE_EVENT_DamageVeryShort_ERROR);
			valueNumber =  format.parse(newDamageVeryShort);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setDamageVeryShort(talentReference,valueInteger);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageVeryShortStatus(true);	
			}
			addStateEvent(STATE_EVENT_DamageVeryShort_ERROR);			
		}	
	} 
	
	public void modifyDamageShort(UUID talentUUID,String newDamageShort) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageShortStatus(false);
			}
			removeStateEvent(STATE_EVENT_DamageShort_ERROR);
			valueNumber =  format.parse(newDamageShort);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setDamageShort(talentReference,valueInteger);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageShortStatus(true);	
			}
			addStateEvent(STATE_EVENT_DamageShort_ERROR);			
		}	
	}
		
	public void modifyDamageMedium(UUID talentUUID,String newDamageMedium) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageMediumStatus(false);
			}
			removeStateEvent(STATE_EVENT_DamageMedium_ERROR);
			valueNumber =  format.parse(newDamageMedium);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setDamageMedium(talentReference,valueInteger);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageMediumStatus(true);	
			}
			addStateEvent(STATE_EVENT_DamageMedium_ERROR);			
		}	
	}
	
	public void modifyDamageLong(UUID talentUUID, String newDamageLong) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageLongStatus(false);
			}
			removeStateEvent(STATE_EVENT_DamageLong_ERROR);
			valueNumber =  format.parse(newDamageLong);		
			if (valueNumber instanceof Integer) {
				Integer valueInteger = (Integer) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setDamageLong(talentReference,valueInteger);
			}
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageLongStatus(true);	
			}
			addStateEvent(STATE_EVENT_DamageLong_ERROR);			
		}	
	}
	
	public void modifyDamageExtremelyLong(UUID talentUUID, String newDamageExtremelyLong) {	
		if(facet == null) return;	
		Number valueNumber;
		try {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageExtremelyLongStatus(false);
			}
			removeStateEvent(STATE_EVENT_DamageExtremelyLong_ERROR);
			valueNumber =  format.parse(newDamageExtremelyLong);		
			if (valueNumber instanceof Long) {
				Long valueLong = (Long) valueNumber;
				UUIDReference talentReference = facet.getTalentReferenceForUUID(talentUUID);
				facet.setDamageExtremelyLong(talentReference,valueLong.intValue());
			}			
		} catch (ParseException e) {
			if(compositeEditWeaponRanged != null){
				compositeEditWeaponRanged.setDecorationDamageExtremelyLongStatus(true);	
			}
			addStateEvent(STATE_EVENT_DamageExtremelyLong_ERROR);			
		}	
	}
	
	public void updateTalents(List<UUIDReference> talents){
		if(compositeEditWeaponRanged == null)return;		
		int size = talents.size();
		int i = 0;
		String[] talentNames	= new String[size];
		UUID[] talentUuids		= new UUID[size];			
		for (UUIDReference references : talents) {
			talentNames[i] = references.getSavedName();
			talentUuids[i] = references.getSavedUuid();
			i++;
		}
		compositeEditWeaponRanged.setTalents(talentNames, talentUuids);		
	}
	
	public void updateTp(String newTp) {
		if(newTp != null && compositeEditWeaponRanged != null){
			if( ! newTp.equals(FacetWeaponRanged.UNSET_TP)){				
				compositeEditWeaponRanged.setTp(format.format(newTp));
				removeStateEvent(STATE_EVENT_Tp_WARNING);
			}else{
				compositeEditWeaponRanged.setTp("");
				addStateEvent(STATE_EVENT_Tp_WARNING);
			}				
		}			
	}
	 
	public void updateLoadingActions(Integer newLoadingActions) {
		if(newLoadingActions != null && compositeEditWeaponRanged != null){
			if( ! newLoadingActions.equals(FacetWeaponRanged.UNSET_LOADING_ACTIONS)){				
				compositeEditWeaponRanged.setLoadingActions(format.format(newLoadingActions));
				removeStateEvent(STATE_EVENT_LoadingActions_WARNING);
			}else{
				compositeEditWeaponRanged.setLoadingActions("");
				addStateEvent(STATE_EVENT_LoadingActions_WARNING);
			}				
		}			
	}
	
	public void updateRangeMin(Double newRangeMin) {
		if(newRangeMin != null && compositeEditWeaponRanged != null){
			if( ! newRangeMin.equals(FacetWeaponRanged.UNSET_RANGE_MIN)){				
				compositeEditWeaponRanged.setRangeMin(format.format(newRangeMin));
				removeStateEvent(STATE_EVENT_RangeMin_WARNING);
			}else{
				compositeEditWeaponRanged.setRangeMin("");
				addStateEvent(STATE_EVENT_RangeMin_WARNING);
			}				
		}			
	}	
	
	public void updateRangeVeryShort(Double newRangeVeryShort) {
		if(newRangeVeryShort != null && compositeEditWeaponRanged != null){
			if( ! newRangeVeryShort.equals(FacetWeaponRanged.UNSET_RANGE_VERY_SHORT)){				
				compositeEditWeaponRanged.setRangeVeryShort(format.format(newRangeVeryShort));
				removeStateEvent(STATE_EVENT_RangeVeryShort_WARNING);
			}else{
				compositeEditWeaponRanged.setRangeVeryShort("");
				addStateEvent(STATE_EVENT_RangeVeryShort_WARNING);
			}				
		}			
	}
	
	public void updateRangeShort(Double newRangeShort) {
		if(newRangeShort != null && compositeEditWeaponRanged != null){
			if( ! newRangeShort.equals(FacetWeaponRanged.UNSET_RANGE_SHORT)){				
				compositeEditWeaponRanged.setRangeShort(format.format(newRangeShort));
				removeStateEvent(STATE_EVENT_RangeShort_WARNING);
			}else{
				compositeEditWeaponRanged.setRangeShort("");
				addStateEvent(STATE_EVENT_RangeShort_WARNING);
			}				
		}			
	}
	
	public void updateRangeMedium(Double newRangeMedium) {
		if(newRangeMedium != null && compositeEditWeaponRanged != null){
			if( ! newRangeMedium.equals(FacetWeaponRanged.UNSET_RANGE_MEDIUM)){				
				compositeEditWeaponRanged.setRangeMedium(format.format(newRangeMedium));
				removeStateEvent(STATE_EVENT_RangeMedium_WARNING);
			}else{
				compositeEditWeaponRanged.setRangeMedium("");
				addStateEvent(STATE_EVENT_RangeMedium_WARNING);
			}				
		}			
	}
	
	public void updateRangeLong(Double newRangeLong) {
		if(newRangeLong != null && compositeEditWeaponRanged != null){
			if( ! newRangeLong.equals(FacetWeaponRanged.UNSET_RANGE_LONG)){				
				compositeEditWeaponRanged.setRangeLong(format.format(newRangeLong));
				removeStateEvent(STATE_EVENT_RangeLong_WARNING);
			}else{
				compositeEditWeaponRanged.setRangeLong("");
				addStateEvent(STATE_EVENT_RangeLong_WARNING);
			}				
		}			
	}
	
	public void updateRangeExtremelyLong(Double newRangeExtremelyLong) {
		if(compositeEditWeaponRanged != null){
			if(newRangeExtremelyLong != null && ! newRangeExtremelyLong.equals(FacetWeaponRanged.UNSET_RANGE_EXTREMELY_LONG)){				
				compositeEditWeaponRanged.setRangeExtremelyLong(format.format(newRangeExtremelyLong));
				removeStateEvent(STATE_EVENT_RangeExtremelyLong_WARNING);
			}else{
				compositeEditWeaponRanged.setRangeExtremelyLong("");
				addStateEvent(STATE_EVENT_RangeExtremelyLong_WARNING);
			}				
		}			
	}
	
	public void updateDamageVeryShort(Integer newDamageVeryShort) {
		if(newDamageVeryShort != null && compositeEditWeaponRanged != null){
			if( ! newDamageVeryShort.equals(FacetWeaponRanged.UNSET_DAMAGE_VERY_SHORT)){				
				compositeEditWeaponRanged.setDamageVeryShort(format.format(newDamageVeryShort));
				removeStateEvent(STATE_EVENT_DamageVeryShort_WARNING);
			}else{
				compositeEditWeaponRanged.setDamageVeryShort("");
				addStateEvent(STATE_EVENT_DamageVeryShort_WARNING);
			}				
		}			
	}
	
	public void updateDamageShort(Integer newDamageShort) {
		if(newDamageShort != null && compositeEditWeaponRanged != null){
			if( ! newDamageShort.equals(FacetWeaponRanged.UNSET_DAMAGE_SHORT)){				
				compositeEditWeaponRanged.setDamageShort(format.format(newDamageShort));
				removeStateEvent(STATE_EVENT_DamageShort_WARNING);
			}else{
				compositeEditWeaponRanged.setDamageShort("");
				addStateEvent(STATE_EVENT_DamageShort_WARNING);
			}				
		}			
	}
	
	public void updateDamageMedium(Integer newDamageMedium) {
		if(newDamageMedium != null && compositeEditWeaponRanged != null){
			if( ! newDamageMedium.equals(FacetWeaponRanged.UNSET_DAMAGE_MEDIUM)){				
				compositeEditWeaponRanged.setDamageMedium(format.format(newDamageMedium));
				removeStateEvent(STATE_EVENT_DamageMedium_WARNING);
			}else{
				compositeEditWeaponRanged.setDamageMedium("");
				addStateEvent(STATE_EVENT_DamageMedium_WARNING);
			}				
		}			
	}
	
	public void updateDamageLong(Integer newDamageLong) {
		if(newDamageLong != null && compositeEditWeaponRanged != null){
			if( ! newDamageLong.equals(FacetWeaponRanged.UNSET_DAMAGE_LONG)){				
				compositeEditWeaponRanged.setDamageLong(format.format(newDamageLong));
				removeStateEvent(STATE_EVENT_DamageLong_WARNING);
			}else{
				compositeEditWeaponRanged.setDamageLong("");
				addStateEvent(STATE_EVENT_DamageLong_WARNING);
			}				
		}			
	}
	
	public void updateDamageExtremelyLong(Integer newDamageExtremelyLong) {
		if(compositeEditWeaponRanged != null){
			if(newDamageExtremelyLong != null && ! newDamageExtremelyLong.equals(FacetWeaponRanged.UNSET_DAMAGE_EXTREMELY_LONG)){				
				compositeEditWeaponRanged.setDamageExtremelyLong(format.format(newDamageExtremelyLong));
				removeStateEvent(STATE_EVENT_DamageExtremelyLong_WARNING);
			}else{
				compositeEditWeaponRanged.setDamageExtremelyLong("");
				addStateEvent(STATE_EVENT_DamageExtremelyLong_WARNING);
			}				
		}			
	}
		
	@Override
	protected void updateAll(FacetWeaponRanged facet) {
		if(compositeEditWeaponRanged != null){
			updateTalents(facet.getTalents());	
		}						
	}
	
	protected void updateWeaponValues(WeaponRanged_CombatValues values) {
		updateTp				 (values.getTp());
		updateLoadingActions	 (values.getLoadingActions());
		updateRangeMin			 (values.getRangeMin());
		updateRangeVeryShort	 (values.getRangeVeryShort());
		updateRangeShort		 (values.getRangeShort());
		updateRangeMedium		 (values.getRangeMedium());
		updateRangeLong			 (values.getRangeLong());
		updateRangeExtremelyLong (values.getRangeExtremelyLong());
		updateDamageVeryShort	 (values.getDamageVeryShort());
		updateDamageShort		 (values.getDamageShort());
		updateDamageMedium		 (values.getDamageMedium());
		updateDamageLong		 (values.getDamageLong());
		updateDamageExtremelyLong(values.getDamageExtremelyLong());	
	}
	
	@Override
	protected void updateClearUI() {
		updateTp				 (FacetWeaponRanged.UNSET_TP);
		updateLoadingActions	 (FacetWeaponRanged.UNSET_LOADING_ACTIONS);
		updateRangeMin			 (FacetWeaponRanged.UNSET_RANGE_MIN);
		updateRangeVeryShort	 (FacetWeaponRanged.UNSET_RANGE_VERY_SHORT);
		updateRangeShort		 (FacetWeaponRanged.UNSET_RANGE_SHORT);
		updateRangeMedium		 (FacetWeaponRanged.UNSET_RANGE_MEDIUM);
		updateRangeLong			 (FacetWeaponRanged.UNSET_RANGE_LONG);
		updateRangeExtremelyLong (FacetWeaponRanged.UNSET_RANGE_EXTREMELY_LONG);
		updateDamageVeryShort	 (FacetWeaponRanged.UNSET_DAMAGE_VERY_SHORT);
		updateDamageShort		 (FacetWeaponRanged.UNSET_DAMAGE_SHORT);
		updateDamageMedium		 (FacetWeaponRanged.UNSET_DAMAGE_MEDIUM);
		updateDamageLong		 (FacetWeaponRanged.UNSET_DAMAGE_LONG);
		updateDamageExtremelyLong(FacetWeaponRanged.UNSET_DAMAGE_EXTREMELY_LONG);		
	}
	
	
	@Override
	protected void preSetSection() {
		super.preSetSection();
		if(section != null){
			Control client = section.getClient();
			if (client instanceof CompositeEditWeaponRanged) {
				compositeEditWeaponRanged = (CompositeEditWeaponRanged) client;
				deRegisterUIListeners(compositeEditWeaponRanged);
			}else{
				logger.error("wrong client in section: expected "+CompositeEditWeaponRanged.class.getSimpleName()+
						" got: "+client.getClass().getSimpleName());
			}
		}
	}

	@Override
	protected void postSetSection() {
		super.postSetSection();
		Control client = section.getClient();
		if (client instanceof CompositeEditWeaponRanged) {
			compositeEditWeaponRanged = (CompositeEditWeaponRanged) client;
			registerUIListeners(compositeEditWeaponRanged);
		}else{
			logger.error("wrong client in section: expected "+CompositeEditWeaponRanged.class.getSimpleName()+
					" got: "+client.getClass().getSimpleName());
		}
	}

	protected void registerUIListeners(CompositeEditWeaponRanged compositeEditWeaponRanged) {
		compositeEditWeaponRanged.registerUIListener(uilFacetWeaponRanged);
	}

	protected void deRegisterUIListeners(CompositeEditWeaponRanged compositeEditWeaponRanged) {
		compositeEditWeaponRanged.deRegisterUIListener(uilFacetWeaponRanged);
	}

	@Override
	protected void preSetNewFacet() {
		super.preSetNewFacet();
		if(facet != null){
			deRegisterModelListeners(facet);
		}
	}

	@Override
	protected void postSetNewFacet() {
		super.postSetNewFacet();
		if(facet != null){
			registerModelListeners(facet);			
		}
	}

	protected void registerModelListeners(FacetWeaponRanged facet) {
		facet.getPropertyChangeSupport().addPropertyChangeListener(pclFacetWeaponRanged);
	}

	protected void deRegisterModelListeners(FacetWeaponRanged facet) {
		facet.getPropertyChangeSupport().removePropertyChangeListener(pclFacetWeaponRanged);
	}
	
	public void setTalentResolver(IServiceResolver_EntityTalent serviceResolverTalents) {
		this.serviceResolverTalents = serviceResolverTalents;		
	}

		
	protected UILFacetWeaponRanged uilFacetWeaponRanged;
	protected class UILFacetWeaponRanged implements IUiChangeListener{
		@Override
		public void uiChanged(UiChangeEvent event) {
			int index = event.getIndex();
			UUID selectedUUID = compositeEditWeaponRanged.getSelectedTalentUUID();			
			switch (index) {
				case CompositeEditWeaponRanged.EVT_EDIT_TP:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyTp(selectedUUID,newValue);
					}
					break;
				}		
				case CompositeEditWeaponRanged.EVT_EDIT_LOADING_ACTIONS:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyLoadingActions(selectedUUID,newValue);
					}
					break;
				}	
				case CompositeEditWeaponRanged.EVT_EDIT_RANGE_MIN:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyRangeMin(selectedUUID,newValue);
					}
					break;
				}		
				case CompositeEditWeaponRanged.EVT_EDIT_RANGE_VERY_SHORT:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyRangeVeryShort(selectedUUID,newValue);
					}
					break;
				}				
				case CompositeEditWeaponRanged.EVT_EDIT_RANGE_SHORT:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyRangeShort(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_RANGE_MEDIUM:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyRangeMedium(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_RANGE_LONG:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyRangeLong(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_RANGE_EXTREMELY_LONG:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyRangeExtremelyLong(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_DAMAGE_VERY_SHORT:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyDamageVeryShort(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_DAMAGE_SHORT:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyDamageShort(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_DAMAGE_MEDIUM:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyDamageMedium(selectedUUID,newValue);
					}
					break;
				}
				case CompositeEditWeaponRanged.EVT_EDIT_DAMAGE_LONG:{
					Object obj = event.getNewValue();
					if (obj instanceof String) {
						String newValue = (String) obj;
						modifyDamageLong(selectedUUID,newValue);
					}
					break;
				}				
				default:
					logger.debug("unknown ui-event: "+event);
					break;
			}
		}

		@Override
		public void commandIssued(int index, Object... parameters) {
			//used for talent selection
			switch (index) {
				case CompositeEditWeaponRanged.CMD_TALENT_ADD:{
					handleTalentsAdd();
					break;
				}			
				case CompositeEditWeaponRanged.CMD_TALENT_SELECTED:{
					handleTalentsSelected();							
					break;
				}
				case CompositeEditWeaponRanged.CMD_TALENT_REMOVE:{
					handleTalentsDelete();				
					break;
				}				
				default:{
					logger.error("unknown command issued");
					break;
				}					
			}
		}
	}

	protected PCLFacetWeaponRanged pclFacetWeaponRanged;
	protected class PCLFacetWeaponRanged implements PropertyChangeListener{
		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			if (evt instanceof IndexedPropertyChangeEvent) {
				IndexedPropertyChangeEvent idxEvt = (IndexedPropertyChangeEvent) evt;
				switch (idxEvt.getIndex()) {
					//talents 
					case FacetWeaponRanged.PI_TALENTS_VALUES:{
						if (idxEvt.getNewValue() instanceof Map) {
							Map<?,?> valueMap = (Map<?,?>) idxEvt.getNewValue();
							Set<?> keys = valueMap.keySet();
							List<UUIDReference> talentList = new ArrayList<UUIDReference>();
							for (Object key : keys) {
								if (key instanceof UUIDReference) {
									UUIDReference talentReference = (UUIDReference) key;
									talentList.add(talentReference);
								} else {
									String err_msg = "entity of wrong type in propertyChange : \n"
											+ "Expected: "
											+ UUIDReference.class.getSimpleName()
											+ "\n"
											+ "Got: "
											+ (key == null ? "null" : key
													.getClass().getSimpleName());
									logger.error(err_msg);
								}
							}
							updateTalents(talentList);							
						}
						break;
					}
					//weapon combat values
					case FacetWeaponRanged.PI_TP:{
						if (idxEvt.getNewValue() instanceof String) {
							String value = (String) idxEvt.getNewValue();
							updateTp(value);
						}
						break;
					}			
					case FacetWeaponRanged.PI_LOADING_ACTIONS:{
						if (idxEvt.getNewValue() instanceof Integer) {
							Integer value = (Integer) idxEvt.getNewValue();
							updateLoadingActions(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_RANGE_VERY_SHORT:{
						if (idxEvt.getNewValue() instanceof Double) {
							Double value = (Double) idxEvt.getNewValue();
							updateRangeVeryShort(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_RANGE_SHORT:{
						if (idxEvt.getNewValue() instanceof Double) {
							Double value = (Double) idxEvt.getNewValue();
							updateRangeShort(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_RANGE_MEDIUM:{
						if (idxEvt.getNewValue() instanceof Double) {
							Double value = (Double) idxEvt.getNewValue();
							updateRangeMedium(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_RANGE_LONG:{
						if (idxEvt.getNewValue() instanceof Double) {
							Double value = (Double) idxEvt.getNewValue();
							updateRangeLong(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_DAMAGE_VERY_SHORT:{
						if (idxEvt.getNewValue() instanceof Integer) {
							Integer value = (Integer) idxEvt.getNewValue();
							updateDamageVeryShort(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_DAMAGE_SHORT:{
						if (idxEvt.getNewValue() instanceof Integer) {
							Integer value = (Integer) idxEvt.getNewValue();
							updateDamageShort(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_DAMAGE_MEDIUM:{
						if (idxEvt.getNewValue() instanceof Integer) {
							Integer value = (Integer) idxEvt.getNewValue();
							updateDamageMedium(value);
						}
						break;
					}		
					case FacetWeaponRanged.PI_DAMAGE_LONG:{
						if (idxEvt.getNewValue() instanceof Integer) {
							Integer value = (Integer) idxEvt.getNewValue();
							updateDamageLong(value);
						}
						break;
					}					
					default:
						logger.debug("unknown pcl-event: "+evt);
						break;
				}
			}
		}
	}
	
	
	
	
	
	
	
}
